﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="OderMaster.aspx.cs" Inherits="OderMaster" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<html>
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>工单系统</title>
    <link href="../../css/ExtStyle.css" rel="stylesheet" type="text/css" />
    <link href="../../js/plugins/layer/skin/layer.css" rel="stylesheet" />

    <script src="../../js/jquery/jquery-3.2.1.min.js" type="text/javascript"></script>
    <script src="../../js/extTools.js" type="text/javascript"></script>
    <script src="../../js/config.js" type="text/javascript"></script>
    <script src="../../js/plugins/layer/layer.min.js"></script>
    <style type="text/css">
        .btns {
            border-left: 1px solid #9A9A9A;
            border-right: 1px solid #9A9A9A;
            border-bottom: 1px solid #9A9A9A;
            padding: 4px 8px;
            background-color: #E3FBE3;
        }

        .btn {
            background-color: #FFFFFF;
            border-radius: 3px;
            color: #000000;
            padding: 2px 10px;
            border: 1px solid #9A9A9A;
            cursor: pointer;
            margin: 0px 4px;
        }

        .conditions {
            border-left: 1px solid #9A9A9A;
            border-right: 1px solid #9A9A9A;
            border-bottom: 1px solid #9A9A9A;
            padding: 4px 8px;
        }

        .form {
            background-color: rgba(251, 249, 249, 0.00);
        }

        .x-column-form-item {
            margin: 0px 4px;
        }

        .ck_a_type {
            font-size: 10px;
            font-weight: 600;
            text-shadow: none;
            padding: 3px 8px;
            background-color: #9A9A9A;
            color: #FFF;
            text-align: center;
            white-space: nowrap;
            vertical-align: baseline;
            border-radius: .25em;
        }

        .ck_a_type_2, .ck_a_type_3 {
            display: none;
        }

        .ck_b_type {
            font-size: 10px;
            font-weight: 600;
            text-shadow: none;
            padding: 4px 8px;
            background-color: red;
            color: #FFF;
            text-align: center;
            white-space: nowrap;
            vertical-align: baseline;
            border-radius: .25em;
        }

        .ck_b_type_1, .ck_b_type_3 {
            display: none;
        }

        .ck_c_type {
            font-size: 10px;
            font-weight: 600;
            text-shadow: none;
            padding: 4px 8px;
            background-color: #1ab394;
            color: #FFF;
            text-align: center;
            white-space: nowrap;
            vertical-align: baseline;
            border-radius: .25em;
        }

        .ck_c_type_1, .ck_c_type_2 {
            display: none;
        }

        .sp_d_line {
            margin: 0px 8px;
        }

        .sp_d_line_2, .sp_d_line_3, .a_w_type_2, .a_w_type_3 {
            display: none;
        }

        .hide {
            display: none;
        }
    </style>
    <script type="text/javascript">

        function openCreate() {
            var index = layer.open({
                type: 2,
                anim: 2,
                isOutAnim: true,
                title: '创建工单',
                content: 'OrderInfo.aspx',
                area: ['800px', '600px'],
                maxmin: true,
                cancel: function (index, layero) {
                    layer.close(index);
                    CompanyX.BtnQurey();
                }
            });
            layer.full(index);
        }
        function viewDetal(w_id) {
            var index = layer.open({
                type: 2,
                anim: 2,
                isOutAnim: true,
                title: '查看工单',
                content: 'OrderInfo.aspx?viewState=Query&wId=' + w_id,
                area: ['800px', '600px'],
                maxmin: true,
                cancel: function (index, layero) {
                    layer.close(index);
                    CompanyX.BtnQurey();
                }
            });
            layer.full(index);
        }
        function viewDelect(w_id, w_type) {
            var customUserType = parseInt($("[name='CustomUserType']").val());
            if (w_type == 1) {
                layer.confirm('确定要删除工单？', { icon: 3, title: '提示' }, function (index) {
                    layer.close(index);
                    var _param = { action: 'DelectByWId', wId: w_id }
                    $.ajax({
                        type: "post",
                        url: 'WorkOrder.ashx',
                        data: _param,
                        dataType: "json",
                        success: function (rstData) {
                            if (rstData.Success) {
                                layer.msg('删除成功！', { icon: 1, time: 2000 });
                                CompanyX.BtnQurey();
                            } else {
                                layer.msg(rstData.Message, { icon: 2, time: 2000 });
                            }
                        }
                    });
                });
            } else {
                layer.msg('只有审批中的工单才可以删除!', { icon: 4, time: 2000 });
            }
        }
        $(function () {
            CompanyX.BtnQurey();
            var userID = $("[name='UserID']").val();
            var customUserType = parseInt($("[name='CustomUserType']").val());
            if (customUserType == 1) {
                $('#btnCreate').addClass('hide');
            } else {
                $('#btnCreate').removeClass('hide');
            }
        });
    </script>
</head>
<body>
    <ext:ResourceManager ID="ResourceManager1" runat="server" Theme="Neptune" />
    <ext:Viewport ID="Viewport1" runat="server" Layout="FitLayout">
        <Items>
            <ext:GridPanel ID="gpList" runat="server" AutoScroll="true" Flex="1">
                <TopBar>
                    <ext:Toolbar ID="Toolbar1" runat="server" Layout="TableLayout">
                        <Items>
                            <ext:FormPanel runat="server" Layout="ColumnLayout">
                                <Items>
                                    <ext:TextField runat="server" ID="txtW_Code" FieldLabel="工单编号" Width="200" LabelWidth="60"></ext:TextField>
                                    <ext:DateField runat="server" ID="txtTimeBegin" FieldLabel="提交时间" Editable="false" Width="160" LabelWidth="60" />
                                    <ext:DateField runat="server" ID="txtTimeEnd" FieldLabel="至" Editable="false" Width="120" LabelWidth="20" />
                                    <ext:ComboBox runat="server" ID="cbParentCode" QueryMode="Local" TypeAhead="true" FieldLabel="巡检类别" ValueField="Code" DisplayField="Name" Width="200" LabelWidth="60">
                                        <Store>
                                            <ext:Store ID="ParentStore" runat="server" AutoDataBind="true">
                                                <Model>
                                                    <ext:Model ID="ParentModel" runat="server">
                                                        <Fields>
                                                            <ext:ModelField Name="Code" />
                                                            <ext:ModelField Name="Name" />
                                                        </Fields>
                                                    </ext:Model>
                                                </Model>
                                            </ext:Store>
                                        </Store>
                                    </ext:ComboBox>
                                    <ext:ComboBox runat="server" ID="cbW_Type" QueryMode="Local" TypeAhead="true" DisplayField="Name" ValueField="Value" FieldLabel="状态" Width="130" LabelWidth="30">
                                        <Store>
                                            <ext:Store ID="TypeStore" runat="server" AutoDataBind="true">
                                                <Model>
                                                    <ext:Model ID="TypeModel" runat="server">
                                                        <Fields>
                                                            <ext:ModelField Name="Name" />
                                                            <ext:ModelField Name="Value" Type="Int" />
                                                        </Fields>
                                                    </ext:Model>
                                                </Model>
                                            </ext:Store>
                                        </Store>
                                    </ext:ComboBox>
                                    <ext:Button ID="btnQuery" Cls="btn btnQuery" Text="查询" runat="server" OnDirectClick="btnQuery_DirectClick">
                                        <DirectEvents>
                                            <Click>
                                                <EventMask ShowMask="true" Msg="加载中..."></EventMask>
                                            </Click>
                                        </DirectEvents>
                                    </ext:Button>
                                    <ext:Button ID="btnCreate" Cls="btn" Text="创建" runat="server" OnClientClick="openCreate()" />
                                </Items>
                            </ext:FormPanel>

                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <Store>
                    <ext:Store ID="gpStore" runat="server" PageSize="500" OnReadData="RefreshDataSet">
                        <Model>
                            <ext:Model ID="gpListStore" runat="server" IDProperty="店铺任务完成率">
                                <Fields>
                                    <ext:ModelField Name="w_id" />
                                    <ext:ModelField Name="w_code" />
                                    <ext:ModelField Name="ShopName" />
                                    <ext:ModelField Name="tif_checkDate" />
                                    <ext:ModelField Name="ins_checkContext" />
                                    <ext:ModelField Name="ins_parentName" />
                                    <ext:ModelField Name="CreateBy" />
                                    <ext:ModelField Name="CreateDate" />
                                    <ext:ModelField Name="w_type" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ColumnModel>
                    <Columns>
                        <ext:RowNumbererColumn ID="RowNumbererColumn1" runat="server" />
                        <ext:Column ID="cl_w_code" runat="server" Text="工单编号" DataIndex="w_code" Width="140" />
                        <ext:Column ID="cl_tif_shopName" runat="server" Text="店铺" DataIndex="ShopName" Width="120" />
                        <ext:DateColumn ID="cl_tif_checkDate" runat="server" Text="巡店时间" DataIndex="tif_checkDate" Format="yyyy-MM-dd" Width="100" />
                        <ext:Column ID="cl_ins_checkContext" runat="server" Text="问题内容" DataIndex="ins_checkContext" Flex="1" />
                        <ext:Column ID="cl_ins_parentName" runat="server" Text="巡检类别" DataIndex="ins_parentName" Width="100" />
                        <ext:Column ID="cl_wd_submitter" runat="server" Text="提交人" DataIndex="CreateBy" Width="100" />
                        <ext:DateColumn ID="cl_createDate" runat="server" Text="提交时间" DataIndex="CreateDate" Format="yyyy-MM-dd HH:mm:ss" Width="150" />
                        <ext:TemplateColumn ID="cl_w_type" runat="server" Text="状态" DataIndex="w_type" Width="100">
                            <Template runat="server">
                                <Html>
                                    <label class="ck_a_type ck_a_type_{w_type}">审核中</label>
                                    <label class="ck_b_type ck_b_type_{w_type}">驳回</label>
                                    <label class="ck_c_type ck_c_type_{w_type}">同意</label>
                                </Html>
                            </Template>
                        </ext:TemplateColumn>
                        <ext:TemplateColumn ID="cl_operation" runat="server" Text="操作" Width="120">
                            <Template runat="server">
                                <Html>
                                    <div class="table-operation">
                                        <a href="javascript:void(0)" onclick="viewDetal({w_id})">查看</a>
                                        <span class="sp_d_line sp_d_line_{w_type}">|</span>
                                        <a class="a_w_type_{w_type}" href="javascript:void(0)" onclick="viewDelect({w_id},{w_type})">删除</a>
                                    </div>
                                </Html>
                            </Template>
                        </ext:TemplateColumn>
                    </Columns>
                </ColumnModel>
                <BottomBar>
                    <ext:PagingToolbar ID="pagaList" runat="server">
                        <Items>
                            <ext:Label ID="Label1" runat="server" Text="每页显示:" />
                            <ext:ToolbarSpacer ID="ToolbarSpacer1" runat="server" Width="10" />
                            <ext:ComboBox ID="ComboBox1" runat="server" Width="80">
                                <Items>
                                    <ext:ListItem Text="500" />
                                </Items>
                                <SelectedItems>
                                    <ext:ListItem Value="500" />
                                </SelectedItems>
                                <Listeners>
                                    <Select Handler="#{gpList}.store.pageSize = parseInt(this.getValue(), 10); #{gpList}.store.reload();" />
                                </Listeners>
                            </ext:ComboBox>
                        </Items>
                        <Plugins>
                            <ext:ProgressBarPager ID="ProgressBarPager1" runat="server" />
                        </Plugins>
                    </ext:PagingToolbar>
                </BottomBar>
            </ext:GridPanel>
            <ext:Hidden ID="UserID" Name="UserID" Text="" runat="server" />
            <ext:Hidden ID="UserName" Name="UserName" Text="" runat="server" />
            <ext:Hidden ID="CustomUserType" Name="CustomUserType" Text="" runat="server" />
        </Items>
    </ext:Viewport>
</body>
</html>
